function [Kb, Vb] = initializeKandV(indices,Z,gnd)

n = length(gnd);
k = length(unique(gnd));

%%% Initialize K

Kb = rand(n);

idx_a = (Z==1);
Kb = Kb - Kb.*idx_a + Z.*idx_a;
idx_b = (Z==-1);
Kb = Kb - Kb.*idx_b;

Kb = (Kb+Kb')/2;


%%% Initialize V
Vb = rand(n,k);
Vb = Vb./repmat(sum(Vb,2),1,k);

indices = indices';
Vb(indices,:) = 0;
Vb(sub2ind(size(Vb),indices,gnd(indices))) = 1;

end

